﻿Imports System.Data.OleDb

Public Class ErrorDAO
    Private strConnectString As String
    'Public Sub New(ByVal sConnectString As String)
    '    Try
    '        strConnectString = sConnectString
    '    Catch ex As Exception
    '    End Try
    'End Sub

    Public Sub New()

    End Sub

    Public Sub SaveError(ByVal MessageError As String, _
                         ByVal FormName As String, _
                         ByVal ProcedureName As String, _
                         ByVal UserFullName As String)
        Dim myCommand As New OleDbCommand
        Dim myConn As New OleDbConnection
        myConn.ConnectionString = strConnectString

        Try
            If myConn.State = ConnectionState.Closed Then myConn.Open()
            With myCommand
                .Connection = myConn
                .CommandText = "spTDT_ErrorLog_Insert"
                .CommandType = CommandType.StoredProcedure

                '.Parameters.Add("@Application", FormName)
                .Parameters.Add("@Application")
                .Parameters("@Application").Value = FormName

                '.Parameters.Add("@ProcedureName", ProcedureName)
                .Parameters.Add("@ProcedureName")
                .Parameters("@ProcedureName").Value = ProcedureName

                '.Parameters.Add("@ErrorMessage", MessageError)
                .Parameters.Add("@ErrorMessage")
                .Parameters("@ErrorMessage").Value = MessageError

                '.Parameters.Add("@UserFullName", UserFullName)
                .Parameters.Add("@UserFullName")
                .Parameters("@UserFullName").Value = UserFullName

                .ExecuteNonQuery()



            End With
        Catch ex As Exception
        Finally
            myCommand.Dispose()
            If myConn.State = ConnectionState.Open Then myConn.Close()
        End Try
    End Sub

    Public Sub SaveError_v2(ByVal MessageError As String, _
                            ByVal FormName As String, _
                            ByVal ProcedureName As String, _
                            ByVal UserFullName As String)
        Try
            Dim para(3) As OleDbParameter
            para(0) = New OleDbParameter("@Application", FormName)
            para(0).OleDbType = OleDbType.VarWChar

            para(1) = New OleDbParameter("@ProcedureName", ProcedureName)
            para(1).OleDbType = OleDbType.VarWChar

            para(2) = New OleDbParameter("@ErrorMessage", MessageError)
            para(2).OleDbType = OleDbType.VarWChar

            para(3) = New OleDbParameter("@UserFullName", UserFullName)
            para(3).OleDbType = OleDbType.VarWChar

            objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ErrorLog_Insert", para)

        Catch ex As Exception

        End Try

        'Dim myCommand As New OleDbCommand
        'Dim myConn As New OleDbConnection
        'myConn.ConnectionString = strConnectString

        'Try
        '    If myConn.State = ConnectionState.Closed Then myConn.Open()
        '    With myCommand
        '        .Connection = myConn
        '        .CommandText = "spTDT_ErrorLog_Insert"
        '        .CommandType = CommandType.StoredProcedure

        '        '.Parameters.Add("@Application", FormName)
        '        .Parameters.Add("@Application")
        '        .Parameters("@Application").Value = FormName

        '        '.Parameters.Add("@ProcedureName", ProcedureName)
        '        .Parameters.Add("@ProcedureName")
        '        .Parameters("@ProcedureName").Value = ProcedureName

        '        '.Parameters.Add("@ErrorMessage", MessageError)
        '        .Parameters.Add("@ErrorMessage")
        '        .Parameters("@ErrorMessage").Value = MessageError

        '        '.Parameters.Add("@UserFullName", UserFullName)
        '        .Parameters.Add("@UserFullName")
        '        .Parameters("@UserFullName").Value = UserFullName

        '        .ExecuteNonQuery()
        '    End With
        'Catch ex As Exception
        'Finally
        '    myCommand.Dispose()
        '    If myConn.State = ConnectionState.Open Then myConn.Close()
        'End Try

    End Sub
End Class
